<template>
  <div class="top_wrap">
    <nav class="app-topnav">
      <div class="container">
        <ul>
          <li>
            <a href="javascript:;"
              ><i class="iconfont icon-user"></i>
              {{ $store.state.profile.account }}
            </a>
          </li>
          <li @click="quit" v-if="$store.state.profile.account">
            <a v href="javascript:;">退出登录</a>
          </li>
          <li @click="toLogin" v-if="!$store.state.profile.account">
            <a href="javascript:;">请先登录</a>
          </li>
          <li><a href="javascript:;">免费注册</a></li>
          <li><a href="javascript:;">我的订单</a></li>
          <li><a href="javascript:;">会员中心</a></li>
          <li><a href="javascript:;">帮助中心</a></li>
          <li><a href="javascript:;">关于我们</a></li>
          <li>
            <a href="javascript:;"><i class="iconfont icon-phone"></i>手机版</a>
          </li>
        </ul>
      </div>
    </nav>
  </div>
</template>
<script>
export default {
  methods: {
    quit () {
      // 退出登录
      localStorage.token = ''
      this.$store.commit('setUser', {})
      this.$store.commit('setToken', '')
      this.$router.push('/login')
    },
    toLogin () {
      this.$router.push('/login')
    }
  }
}
</script>
<style lang="less" scoped>
.top_wrap {
  height: 53px;
  line-height: 53px;
  background: #333;
  width: 100%;
  color: white;
}
.app-topnav {
  width: 1240px;
  margin: 0 auto;
  background: #333;
  ul {
    display: flex;
    height: 53px;
    justify-content: flex-end;
    align-items: center;
    li {
      a {
        padding: 0 15px;
        color: #cdcdcd;
        line-height: 1;
        display: inline-block;
        i {
          font-size: 14px;
          margin-right: 2px;
        }
        &:hover {
          color: #27bb9a;
        }
      }
      ~ li {
        a {
          border-left: 2px solid #666;
        }
      }
    }
  }
}
</style>
